package com.example.springboot.demo.easyrules.rules;

import lombok.extern.slf4j.Slf4j;
import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
import org.jeasy.rules.annotation.Rule;

/**
 * @Author dengkaibing
 * @Date 2023/3/6 16:20
 * @Desc
 */
@Rule(name ="grayRule",description = "灰度规则")
@Slf4j
public class CustomizeRulesAnnotation {

    /**
     * 条件组
     * @param grayFlag
     * @return
     */
    @Condition
    public boolean isGray(@Fact("gray") String grayFlag){
        log.info("isGray:{}",grayFlag);
        return "gray".equals(grayFlag);
    }

    @Action
    public void returnProbability2(){
        log.info("CustomizeRulesAnnotation2");
    }

    /**
     * 行为
     */
    @Action
    public void returnProbability(){
        log.info("CustomizeRulesAnnotation");
    }



}
